package com.atguigu.gulimall.ware.dao;

import com.atguigu.common.to.HasStockVo;
import com.atguigu.gulimall.ware.entity.WareSkuEntity;
import com.atguigu.gulimall.ware.service.impl.WareSkuServiceImpl;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 商品库存
 * 
 * @author shujun
 * @email 961624576@qq.com
 * @date 2024-01-14 18:19:44
 */
@Mapper
public interface WareSkuDao extends BaseMapper<WareSkuEntity> {

    void addStock(@Param("skuId") Long skuId, @Param("wareId") Long wareId, @Param("skuNum") Integer skuNum);

    List<HasStockVo> hasStock(@Param("skuIds") List<Long> skuIds);

    List<Long> findSkuHasStockWare(@Param("skuId") Long skuId);

    Integer tryLockStock(@Param("skuId") Long skuId, @Param("wareId") Long wareId, @Param("count") Integer count);

    void unlockStock(@Param("skuId") Long skuId, @Param("wareId") Long wareId, @Param("skuNum") Integer skuNum);
}
